//
// Created by Lenovo on 2020/10/12.
//
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
const int maxn = 1e9+1;
const int N = 1e6+10;
ll prime[N];
bool vis[N];
void init()
{
    int cnt = 0;
    vis[0] = true;
    vis[1] = true;
    for(int i = 2;i<=N;i++)
    {
        if(!vis[i]) prime[cnt++] = i;
        for(int j = 2;j*i<=N;j++) vis[j*i] = true;
    }
}
ll dfs(ll n,int pos)
{
    if(pos==-1) return n;
    if(prime[pos]>=n) return 1;
    return dfs(n,pos-1) - dfs(n/prime[pos],pos-1);
}
int main()
{
    init();
    ll x,y;
    cin>>x>>y;
    int ct = 0;
    while(prime[ct]<y) ct++;
    ll l = y;
    ll r = maxn;
    while(l<r)
    {
        ll mid = (l+r)>>1;
        ll t = dfs(mid/y,ct-1);
        if(t>=x) r = mid;
        else l = mid+1;
    }
    if(r>1e9) cout<<0<<endl;
    else cout<<r<<endl;
}